import { defineStore } from 'pinia';
import { http } from '@/utils/request';
import type { topSortList, cateResult } from '@/types/index';
export const useCategoryStore = defineStore('cate', {
  // 开启本地存储
  persist: true,
  state() {
    return {
      topSortList: [] as topSortList,
      name: '',
      selectId: '',
    };
  },
  actions: {
    async getTopCate(id: string) {
      const result = await http<cateResult>('get', '/category', { id });
      console.log(result, '一级类目');
      this.topSortList = result.data.result.children;
      console.log(this.topSortList);
      this.name = result.data.result.name;
      console.log(this.name, 'name');
    },
  },
});
